#define _CRT_SECURE_NO_WARNINGS
#pragma warning(disable:6031)

#include <stdio.h>
#include <assert.h>

char* my_strstr(const char* scan, const char* match)
{
	char* ret = scan;
	char* current = match;

	assert(scan != NULL);
	assert(match != NULL);

	while (*scan != '\0')
	{
		if (*scan == *current)
		{
			scan++;
			current++;
			if (*current == '\0')
			{
				return ret;
			}
		}
		else
		{
			scan++;
			ret = scan;
			current = match;
		}
	}
	
	return NULL;
}

int main()
{
	char str1[20] = "zhaojianguo";
	char substr[20] = "\0";
	char* p = my_strstr(str1, substr);
	if (p != NULL)
	{
		printf("%s", p);
	}
	else
	{
		printf("There is no such substring!");
	}

	return 0;
}